package com.snailct.bpp.service.client.factory;

import com.snailct.bpp.commons.utils.PropertiesUtil;
import com.snailct.bpp.service.client.IServiceInvoker;
import com.snailct.bpp.service.client.support.HttpServiceInvoker;
import com.snailct.bpp.service.client.support.WSServiceInvoker;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 客户端调用服务入口API
 * Created by huangxa on 2016/7/26.
 */
public abstract class ServiceInvokerFactory {
    private static final Log logger = LogFactory.getLog(ServiceInvokerFactory.class);
    private enum InvokerType{
        WS,
        HTTP
    }
    public static IServiceInvoker getServiceInvoker(){
        String invokerType = PropertiesUtil.getPropValue("invokerType");
        if(InvokerType.WS.name().equals(invokerType)){
            logger.warn("InvokerType is null.Use Web Service invoker!");
            return new WSServiceInvoker();
        }
        if(InvokerType.HTTP.name().equals(invokerType)){
            //http请求
            return new HttpServiceInvoker();
        }
        return new HttpServiceInvoker();
    }
}
